/*
 * Created: 2022-08-25 19:34:30
 * Author : 涛涛涛
 */

import React, { FC, useContext } from 'react';
import { View, Text } from '@tarojs/components';
import { styled } from 'linaria/react';
import { useClassName } from '@/utils/index';
import { ProductItemContext } from '@/pages/Home/ProductList/ProductItem/ProductItemContext';
import WillLaunch from './WillLaunch/WillLaunch';
import InProgressOrSellUp from './InProgressOrSellUp/InProgressOrSellUp';

export interface IProps extends ICompProps {}
const StatusMapper = {
    waitForSale: WillLaunch,
    dropping: InProgressOrSellUp,
    soldOut: InProgressOrSellUp,
};
ProductStatus.defaultProps = {} as Partial<IProps>;
function ProductStatus(props: IProps) {
    const { className, style } = props;
    const localClassName = useClassName('ProductStatus', className);
    const product = useContext(ProductItemContext);
    const StatusComp = () => {
        const Comp = StatusMapper[product.status];
        return <Comp></Comp>;
    };
    return (
        <RootView className={localClassName} style={style}>
            {StatusComp()}
        </RootView>
    );
}
export default React.memo(ProductStatus as FC<IProps>);
const RootView = styled(View)`
    &.ProductStatus {
    }
`;
